<!DOCTYPE html>
<html data-th-replace="~{admin/layout :: layout(~{::head/content()}, ~{::body/nav/content()}, ~{::body/ul}, ~{::body/div})}">
<head>
    <title data-th-inline="text">Admin | Edit | [[${project.id}]]</title>
</head>
<body>
<nav>
    <ul>
        <li><a data-th-href="@{/admin}">Admin</a></li>
        <li><a data-th-href="@{/admin/projects}">Projects</a></li>
        <li class="is-active"><a data-th-href="@{'/admin/projects/' + ${project.id}}" aria-current="page">Edit</a></li>
    </ul>
</nav>

<ul>
    <li class="is-active">
        <a data-th-href="@{'/admin/projects/' + ${project.id}}">
            <span class="icon is-small"><i class="far fa-folder-open" aria-hidden="true"></i></span>
            <span>Metadata</span>
        </a>
    </li>
    <li>
        <a data-th-href="@{'/admin/projects/' + ${project.id} + '/info'}">
            <span class="icon is-small"><i class="fas fa-info" aria-hidden="true"></i></span>
            <span>Info</span>
        </a>
    </li>
    <li>
        <a data-th-href="@{'/admin/projects/' + ${project.id} + '/releases'}">
            <span class="icon is-small"><i class="fas fa-download" aria-hidden="true"></i></span>
            <span>Releases</span>
        </a>
    </li>
    <li>
        <a data-th-href="@{'/admin/projects/' + ${project.id} + '/support'}">
            <span class="icon is-small"><i class="far fa-calendar-check" aria-hidden="true"></i></span>
            <span>Support</span>
        </a>
    </li>
    <li>
        <a data-th-href="@{'/admin/projects/' + ${project.id} + '/samples'}">
            <span class="icon is-small"><i class="fas fa-code" aria-hidden="true"></i></span>
            <span>Samples</span>
        </a>
    </li>
</ul>

<div>
    <form data-th-action="@{'/admin/projects/'+${project.id}}" method="post" data-th-object="${project}">
        <div class="columns">
            <div class="column is-one-third">
                <div class="field">
                    <label class="label">Id</label>
                    <div class="control">
                        <input class="input" data-th-classappend="(${#fields.hasErrors('id')}? ' is-danger')"
                               type="text" data-th-field="*{id}" name="id" placeholder="Project id">
                        <p class="help is-danger" data-th-if="${#fields.hasErrors('id')}" data-th-errors="*{id}">Incorrect id</p>
                    </div>
                </div>
                <div class="field">
                    <label class="label">Name</label>
                    <div class="control">
                        <input class="input" data-th-classappend="(${#fields.hasErrors('name')}? ' is-danger')"
                               type="text" data-th-field="*{name}" name="name" placeholder="Name">
                        <p class="help is-danger" data-th-if="${#fields.hasErrors('name')}" data-th-errors="*{name}">Incorrect
                            name</p>
                    </div>
                </div>
                <div class="field">
                    <label class="label">StackOverflow tags</label>
                    <div class="control">
                        <input class="input" data-th-classappend="(${#fields.hasErrors('stackOverflowTags')}? ' is-danger')"
                               type="text" data-th-field="*{stackOverflowTags}" name="stackOverflowTags"
                               data-th-placeholder="*{id}">
                        <p class="help is-danger" data-th-if="${#fields.hasErrors('stackOverflowTags')}" data-th-errors="*{stackOverflowTags}">
                            Incorrect StackOverflow tags</p>
                    </div>
                </div>
            </div>
            <div class="column is-one-third">
                <div class="field">
                    <label class="label">Repository URL</label>
                    <div class="control">
                        <input class="input" data-th-classappend="(${#fields.hasErrors('repoUrl')}? ' is-danger')"
                               type="text" data-th-field="*{repoUrl}" name="repoUrl"
                               placeholder="https://github.com/spring-projects/your-project">
                        <p class="help is-danger" data-th-if="${#fields.hasErrors('repoUrl')}" data-th-errors="*{repoUrl}">
                            Incorrect Repository URL</p>
                    </div>
                </div>
                <div class="field">
                    <label class="label">Status</label>
                    <div class="control">
                        <div class="select" data-th-classappend="(${#fields.hasErrors('status')}? ' is-danger')">
                            <select name="status" data-th-field="*{status}">
                                <option data-th-each="stat : ${statusList}" data-th-value="${stat}" data-th-text="${stat.label}">
                                    Active
                                </option>
                            </select>
                            <p class="help is-danger" data-th-if="${#fields.hasErrors('status')}" data-th-errors="*{status}">
                                Incorrect status</p>
                        </div>
                    </div>
                </div>

            </div>
            <div class="column is-one-third">
                <div class="field">
                    <label class="label">Parent project</label>
                    <div class="control">
                        <input class="input" data-th-classappend="(${#fields.hasErrors('parentProjectId')}? ' is-danger')"
                               type="text" data-th-field="*{parentProjectId}" name="parentProjectId" placeholder="Parent project">
                        <p class="help is-danger" data-th-if="${#fields.hasErrors('parentProjectId')}" data-th-errors="*{parentProjectId}">
                            Incorrect parentId</p>
                    </div>
                </div>
                <div class="field">
                    <label class="label">Support policy</label>
                    <div class="control">
                        <div class="select" data-th-classappend="(${#fields.hasErrors('supportPolicy')}? ' is-danger')">
                            <select name="status" data-th-field="*{supportPolicy}">
                                <option data-th-each="policy : ${supportPolicies}" data-th-value="${policy}" data-th-text="${policy.label}">
                                    Upstream
                                </option>
                            </select>
                            <p class="help is-danger" data-th-if="${#fields.hasErrors('supportPolicy')}" data-th-errors="*{supportPolicy}">
                                Incorrect support policy</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="buttons control is-centered">
            <button type="submit" class="button is-primary">Save</button>
            <a class="button" data-th-href="@{/admin/projects}">Cancel</a>
        </div>
    </form>
    <hr class="hr">
    <h3 class="title is-3">Admin</h3>
    <form data-th-action="@{'/admin/projects/' + ${project.id}} + '/delete'" method="post" class="notification is-light">
        <p>You can delete the project. This action will destroy permanently the project.</p>
        <p style="padding-top:10px;">
            <input type="submit" class="button is-danger" value="Yes, Delete the project"/></p>
    </form>
</div>
</body>
</html>
